import Taro from "@tarojs/taro";

const AccessTokenKey = "ACCESS_TOKEN";
const UserInfoKey = "USER_INFO";
// const RefreshTokenKey = "REFRESH_TOKEN";

// ========== Token 相关 ==========

export function getAccessToken() {
  return Taro.getStorageSync(AccessTokenKey);
}

export function getRefreshToken() {
  return Taro.getStorageSync(RefreshTokenKey);
}

export function setToken(token) {
  if (token != undefined || token != "")
    Taro.setStorageSync(AccessTokenKey, token);
  // Taro.setStorageSync(RefreshTokenKey, token.refreshToken);
}

export function removeToken() {
  Taro.removeStorageSync(AccessTokenKey);
  // Taro.removeStorageSync(RefreshTokenKey);
}

export function getUserInfo() {
  return Taro.getStorageSync(UserInfoKey);
}

export function setUserInfo(info) {
  Taro.setStorageSync(UserInfoKey, info);
}

export function removeUserInfo() {
  Taro.removeStorageSync(UserInfoKey);
}

export function setDeptId(deptId) {
  Taro.setStorageSync("DEPT_ID", deptId);
}

export function reomoveDeptId() {
  Taro.removeStorageSync("DEPT_ID");
}

export function getDeptId() {
  return Taro.getStorageSync("DEPT_ID");
}

export function setPermissions(value) {
  Taro.setStorageSync("PERMISSIONS", value);
}

export function removePermissions() {
  Taro.removeStorageSync("PERMISSIONS");
}

export function getPermissions() {
  return Taro.getStorageSync("PERMISSIONS");
}

export function isNeedToRealNameAuth(userInfo) {
  return userInfo.authStatus == false && userInfo.type == "0";
}
